// Copyright (C) joyinter
// All rights reserved.
// 
// Author : Jiang Li
// Date   : 2004-12-7

#ifndef __SVR_DBMSG_H_COMMON_SVR_BASE__
#define __SVR_DBMSG_H_COMMON_SVR_BASE__

#pragma once

#include <common/base/tinyxml.h>
#include "db_command.h"

namespace JoyServer
{

enum JoyDbMessageType
{
#   define JOY_DBMSG_DEF(type, id) DBMSG_##type = id,
#   include "svr_dbmsgdef.h"
};

class CJoyDbMessage
{
public:
    int     m_type;
    CString m_content;
    CJoyXmlElement* m_root;

    CJoyDbMessage()
    {
        m_type = 0;
        m_root = NULL;
    }
    ~CJoyDbMessage()
    {
        if(m_root != NULL)
        {
            delete m_root;
        }
    }
};

class CJoyDbMsgHandler
{
public:
#   define JOY_DBMSG_DEF(name, id) virtual void OnDbMsg_##name(const CJoyDbMessage&) {}
#   include "svr_dbmsgdef.h"

    virtual void DbMsg_Recv(const CJoyDbMessage& msg);
    virtual void DbMsg_Rowset(CJoyDbCommand& row);
};


} // namespace JoyServer

#endif  // __SVR_DBMSG_H_COMMON_SVR_BASE__